﻿

#include <iostream>
using namespace std;
#include<vector>

int findPoisonedDuration(vector<int>& timeSeries, int duration) {
    int lengthTime = timeSeries.size();
    int sumTime = 0;
    for (int i = 0; i < lengthTime - 1; i++)
    {
        if (timeSeries[i + 1] < timeSeries[i] + duration)
        {
            sumTime += (timeSeries[i + 1] - timeSeries[i]);
        }
        else
        {
            sumTime += duration;
        }
    }
    return sumTime + duration;

}



